<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
   private function _setAutoload(){
        Zend_Loader_Autoloader::getInstance()
                ->registerNamespace('Model_')
                ->registerNamespace('My_');
    }

    private function _setPlugin(){
        $front = Zend_Controller_Front::getInstance();
        $front->registerPlugin(new My_Controller_Plugin());
    }

    private function _setView(){
        $view = new Zend_View();
        //$view->doctype('XHTML1_STRICT');
        $view->headTitle('ShopZ')
             ->setSeparator(' | ');
        $view->env = APPLICATION_ENV;


        $view->headLink()->appendStylesheet('/templates/admin/css/bootstrap.css');

        // Add it to the ViewRenderer
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
            'ViewRenderer'
        );
        $viewRenderer->setView($view);

        // Return it, so that it can be stored by the bootstrap
        return $view;
    }

    private function _setConfigDB(){
        //Dùng Zend_Config_Ini => Đọc
        //Dùng Zend_Register => Lưu lại
        $config = new Zend_Config_Ini(APPLICATION_PATH."/configs/application.ini",APPLICATION_ENV);
        $configDB = $config->database->toArray();
        Zend_Registry::set("configDb", $configDB);
    }

    public function run(){
           $frontController = Zend_Controller_Front::getInstance();
           $this->_setAutoload();
           $this->_setPlugin();
           $this->_setView();
           $this->_setConfigDB();
           $frontController->disPatch();
    }

}

